from pydantic import BaseModel, Field
from typing import Dict, Any, List, Literal, Union

class PlaceholderFillInstruction(BaseModel):
    type: Literal["placeholder"] = "placeholder"
    data: Dict[str, Any] = Field(..., description="Key-value pairs where key is placeholder name (e.g., 'name') and value is the data to fill.")

class CellFillInstruction(BaseModel):
    type: Literal["cell"] = "cell"
    data: Dict[str, Any] = Field(..., description="Key-value pairs where key is cell address (e.g., 'A1', 'B5') and value is the data to fill.")

FillInstruction = Union[PlaceholderFillInstruction, CellFillInstruction]

class FillRequest(BaseModel):
    """
    Request body for filling a template.
    `template_name`: The name of the built-in template to use (e.g., '通用销售报表.xlsx').
    `sheet_instructions`: Maps sheet names to a list of fill instructions for that sheet.
    """
    template_name: str = Field(..., description="The name of the built-in Excel template file (e.g., '通用销售报表.xlsx').")
    sheet_instructions: Dict[str, List[FillInstruction]] = Field(
        ...,
        description="A dictionary where keys are sheet names (e.g., 'Sheet1', '销售数据') and values are lists of fill instructions for that sheet."
    ) 